home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / SML⁄NJ 93+ / Documentation / examples / textbooks / reade / chrisprelude.sml < prev    next >
Encoding:
Text File  |  1995-12-30  |  20.4 KB  |  569 lines  |  [TEXT/R*ch]

  1. (*********************************************************
  2.  | Structure Chrisprelude (general purpose functions)    |
  3.  |                                                       |
  4.  | Chris Reade      Oct 1987                             |
  5.  |                                                       |
  6.  | stringofint added Sept 1991                           |
  7.  | error changed to work for other implementations       |
  8.  | (and ex_undefined renamed as ex_error) July 92        |
  9.  | (Comments at end)                                     |
  10.  *********************************************************)
  11.  
  12. structure Chrisprelude = struct
  13.  
  14. exception ex_error of string;
  15. fun error s = (output(std_out,"ERROR REPORT:\n"^s^"\n"); raise ex_error s);
  16.  
  17. fun equal a b = a=b;
  18.  
  19. structure Combinator = struct
  20. fun I x = x;
  21. fun K x y = x;
  22. fun C f x y = f y x;
  23. fun W f x = f x x;
  24. fun Y f = let fun fixf x = f (fixf) x in fixf end;
  25. fun curry f a b = f(a,b);
  26. fun uncurry f (a,b) = f a b;
  27. fun pair a b = (a,b);
  28. fun fst(x,y) = x;
  29. fun snd(x,y) = y;
  30. fun couple f g x = (f x,g x);
  31. fun repeat f = let fun rptf n x = if n=0 then x else rptf (n-1) (f x);
  32.                    fun check n = if n<0 then error "repeat <0" else n
  33.                in rptf o check end
  34. end; (* of Combinator *)
  35. open Combinator;
  36.  
  37. structure Int = struct
  38. fun plus (a:int) b = a+b;
  39. fun times (a:int) b = a*b;
  40. fun less (a:int) b = b<a;
  41. fun lesseq (a:int) b = b<=a;
  42. fun greater (a:int) b = b>a;
  43. fun greatereq (a:int) b = b>=a;
  44. fun max (a:int) b = if a<b then b else a;
  45. fun min (a:int) b = if a<b then a else b
  46. end; (* of Int *)
  47. open Int;
  48.  
  49. structure Bool = struct
  50. fun non p = not o p;
  51. fun ou p q x = p x orelse q x;
  52. fun et p q x = p x andalso q x
  53. end; (* of Bool *)
  54. open Bool;
  55.  
  56. structure List = struct
  57. fun assoc pairlist default arg
  58.              = let fun search []         = default arg 
  59.                    |   search ((a,b)::x) = if arg = a then b else search x
  60.                in search pairlist end;
  61.  
  62.  
  63.  
  64. fun fold f = let fun foldf a []     = a 
  65.                  |   foldf a (b::x) = foldf (f a b) x 
  66.              in foldf end;
  67. val accumulate = fold;
  68. fun foldright f a x = accumulate (C f) a (rev x);
  69. fun zip f = let fun zf (a::x) (b::y) = f a b :: zf x y 
  70.                 |   zf [] []  = []
  71.                 |   zf _  _   = error "zip with different lengthed lists"
  72.             in zf end;
  73. fun splice f = let fun sf (a::x) (b::y) = f a b :: sf x y 
  74.                    |   sf x [] = x 
  75.                    |   sf [] x = x
  76.                in sf end;
  77. fun filter p = let fun consifp x a = if p a then a::x else x
  78.                in rev o accumulate consifp [] end;
  79. fun exists p = let fun existsp [] = false 
  80.                    |   existsp (a::x) = if p a then true
  81.                                                else existsp x
  82.                in existsp end;
  83. val forall =  non o exists o non;
  84. fun member x a = exists (equal a) x ;
  85. fun contains x y = forall (member y) x;
  86. fun null [] = true
  87. |   null _  = false;
  88. fun hd(a::x) = a 
  89. |   hd []    = error "hd of [] is undefined" 
  90. and tl(a::x) = x 
  91. |   tl []    = error "tl of [] is undefined";
  92. fun cons a x = a::x;
  93. fun append x y = x @ y;
  94.  
  95.    infix 5 upto ;
  96. fun n upto m = if n>m then [] else n::(n+1 upto m);
  97. val revonto = accumulate (C cons);
  98. val reverse = revonto [];
  99. fun link llist = rev (accumulate revonto [] llist) ;
  100. fun linkwith (front,sep,back) l
  101.                = let fun f []  = [back] 
  102.                      |   f [a] = [a,back] 
  103.                      |   f (a::x) = a::sep::f x
  104.                  in link (front::f l)  end;
  105. val pairlists = zip pair;
  106. fun copy n x = repeat (cons x) n [];
  107. val sumlist = accumulate plus 0;
  108. val mullist = accumulate times 1;
  109.  
  110. fun maxlist (a::x) = accumulate max a x 
  111. |   maxlist []     = error "maxlist of [] is undefined";
  112. fun maxposlist x   = accumulate max 0 x;
  113. fun transpose [] = [] 
  114. |   transpose x  = if exists null x 
  115.                    then [] 
  116.                    else (map hd x):: transpose (map tl x);
  117. val length = let fun count n a = n+1
  118.              in accumulate count 0 end;
  119. val drop = repeat tl;
  120. fun split n = if n<0 
  121.               then error "negative subscript error(split failed)"
  122.               else let fun shunt 0 x1 x2      = (rev x1,x2)
  123.                        |   shunt n x1 (a::x2) = shunt (n-1) (a::x1) x2
  124.                        |   shunt _  _  _      = error "list subscript error(split failed)"
  125.               in shunt n [] end;
  126. fun front n x = fst(split n x);
  127. fun back n x = drop (length x - n) x;
  128. fun select n = hd o (drop (n-1));
  129. fun sublist n m x =  front m (drop (n-1) x)
  130. end; (* List *)
  131. open List;
  132.  
  133. structure String = struct
  134. fun concat s1 s2 = s1 ^ s2;
  135. fun show x = output(std_out,x);
  136. fun stringwith (front,sep,back) sl 
  137.                = let fun f []  = [back] 
  138.                      |   f [a] = [a,back] 
  139.                      |   f (a::x) = a::sep::f x
  140.                  in implode (front::f sl)  end;
  141. fun spaces n = implode (copy n " ");
  142. fun newlines n = implode (copy n "\n");
  143. local
  144.   fun cofdig n = chr (n+48);
  145.   fun stringofnat n = if n<10 then cofdig n
  146.                               else stringofnat (n div 10) ^ cofdig (n mod 10)
  147. in
  148.   fun stringofint n = if n<0 then "~" ^ stringofnat(~n)
  149.                             else stringofnat n
  150. end;
  151. fun sless (s:string) s' = s' < s;
  152. fun slesseq (s:string) s' = s' <= s
  153. end; (* String *)
  154. open String
  155.  
  156. end; (* of struct Chrisprelude *)
  157.  
  158.  
  159. (************* COMMENTS ************************************
  160.  
  161.  
  162. Structure Chrisprelude contains the functions
  163. listed in the following signature (and described below):-
  164.  
  165. structure Chrisprelude = struct
  166.    exception ex_error : string
  167.    val error = fn : string -> 'a
  168.    structure Bool =
  169.       struct
  170.          val ou = fn : ('a -> bool) -> ('a -> bool) -> 'a -> bool
  171.          val non = fn : ('a -> bool) -> 'a -> bool
  172.          val et = fn : ('a -> bool) -> ('a -> bool) -> 'a -> bool
  173.          end
  174.    structure List =
  175.       struct
  176.          val exists = fn : ('a -> bool) -> 'a list -> bool
  177.          val maxlist = fn : int list -> int
  178.          val zip = fn : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
  179.          val accumulate = fn : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
  180.          val foldright = fn : ('a -> 'b -> 'b) -> 'b -> 'a list -> 'b
  181.          val cons = fn : 'a -> 'a list -> 'a list
  182.          val maxposlist = fn : int list -> int
  183.          val member = fn : ''a list -> ''a -> bool
  184.          val assoc = fn : (''a * 'b) list -> (''a -> 'b) -> ''a -> 'b
  185.          val append = fn : 'a list -> 'a list -> 'a list
  186.          val null = fn : 'a list -> bool
  187.          val hd = fn : 'a list -> 'a
  188.          val revonto = fn : 'a list -> 'a list -> 'a list
  189.          val linkwith = fn :
  190.             'a list * 'a list * 'a list -> 'a list list -> 'a list
  191.          val copy = fn : int -> 'a -> 'a list
  192.          val splice = fn : ('a -> 'a -> 'a) -> 'a list -> 'a list -> 'a list
  193.          val forall = fn : ('a -> bool) -> 'a list -> bool
  194.          val sumlist = fn : int list -> int
  195.          val mullist = fn : int list -> int
  196.          val length = fn : 'a list -> int
  197.          val drop = fn : int -> 'a list -> 'a list
  198.          val filter = fn : ('a -> bool) -> 'a list -> 'a list
  199.          val back = fn : int -> 'a list -> 'a list
  200.          val upto = fn : int * int -> int list
  201.          val front = fn : int -> 'a list -> 'a list
  202.          val select = fn : int -> 'a list -> 'a
  203.          val pairlists = fn : 'a list -> 'b list -> ('a * 'b) list
  204.          val split = fn : int -> 'a list -> 'a list * 'a list
  205.          val sublist = fn : int -> int -> 'a list -> 'a list
  206.          val transpose = fn : 'a list list -> 'a list list
  207.          val tl = fn : 'a list -> 'a list
  208.          val fold = fn : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
  209.          val reverse = fn : 'a list -> 'a list
  210.          val link = fn : 'a list list -> 'a list
  211.          val contains = fn : ''a list -> ''a list -> bool
  212.          end
  213.    structure Combinator =
  214.       struct
  215.          val uncurry = fn : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
  216.          val I = fn : 'a -> 'a
  217.          val couple = fn : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c
  218.          val K = fn : 'a -> 'b -> 'a
  219.          val curry = fn : ('a * 'b -> 'c) -> 'a -> 'b -> 'c
  220.          val snd = fn : 'a * 'b -> 'b
  221.          val W = fn : ('a -> 'a -> 'b) -> 'a -> 'b
  222.          val Y = fn : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b
  223.          val repeat = fn : ('a -> 'a) -> int -> 'a -> 'a
  224.          val C = fn : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
  225.          val pair = fn : 'a -> 'b -> 'a * 'b
  226.          val fst = fn : 'a * 'b -> 'a
  227.          end
  228.    structure String =
  229.       struct
  230.          val slesseq = fn : string -> string -> bool
  231.          val sless = fn : string -> string -> bool
  232.          val stringofint = fn : int -> string
  233.          val stringwith = fn : string * string * string -> string list -> string
  234.          val spaces = fn : int -> string
  235.          val newlines = fn : int -> string
  236.          val show = fn : string -> unit
  237.          val concat = fn : string -> string -> string
  238.          end
  239.    structure Int =
  240.       struct
  241.          val greatereq = fn : int -> int -> bool
  242.          val min = fn : int -> int -> int
  243.          val greater = fn : int -> int -> bool
  244.          val max = fn : int -> int -> int
  245.          val lesseq = fn : int -> int -> bool
  246.          val times = fn : int -> int -> int
  247.          val less = fn : int -> int -> bool
  248.          val plus = fn : int -> int -> int
  249.          end
  250.  
  251. DESCRIPTION OF FUNCTIONS
  252.  
  253. The functions described here are (mostly) of general use in
  254. constructing further functions.
  255. Some are more specialised and are included to illustrate
  256. ways in which functions can be defined and used in ML.
  257. (One or two higher order functions may look obscure because of
  258. the amount of parameterisation, but they are flexible and can
  259. be easily specialised once understood.)
  260. Each function is given with its type, a brief description and
  261. its actual definition.
  262.  
  263. error : string -> 'a
  264. When error is applied to any string, the result is undefined
  265. (the result type is arbitrary since there is no result).
  266. The purpose of error is to  cause the program to abort with the
  267. error message supplied as its argument when such an application
  268. is evaluated in some larger expression.
  269. (See the definitions of hd and tl for examples of its use.)
  270. Evaluation abortion is achieved using ML's exception mechanism,
  271. but exceptions are not defined or raised anywhere else in these
  272. definitions other than through applications of 'error'.
  273. (ex_error is the name of the (only) exception raised).
  274.  
  275. Boolean Related Functions *********************
  276. ou : ('a -> bool) -> ('a -> bool) -> 'a -> bool
  277. combines predicates using 'or' so that
  278. ou p q a = p a orelse q a
  279.  
  280. et : ('a -> bool) -> ('a -> bool) -> 'a -> bool
  281. combines predicates using 'and' so that
  282. et p q a = p a andalso q a
  283.  
  284. non : ('a -> bool) -> 'a -> bool
  285. negates a predicate so that
  286. non p a = not(p a)
  287.  
  288. List Operations *******************************
  289. exists : ('a -> bool) -> 'a list -> bool   
  290. exists p x is true if x contains an item satisfying
  291. predicate p and isfalse otherwise.
  292.  
  293. maxlist : int list -> int   
  294. maxlist x produces the maximum integer in list x (x non-empty)
  295. and raises ex_undefined if x is empty.
  296.  
  297. zip : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list   
  298. zip extends two place functions to act on lists in a
  299. zip-fastener fashion.
  300. e.g. zip f [a1,a2,...,an] [b1,b2,...,bn] = [f a1 b1, f a2 b2,..., f an bn] 
  301. zip raises ex_undefined if the list lengths are not the same.
  302.  
  303. accumulate : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a   
  304. accumulate is a synonym for fold.
  305.  
  306. foldright : ('a -> 'b -> 'b) -> 'b -> 'a list -> 'b  
  307. foldright is similar to accumulate/fold but associating the
  308. argument-function applications to the right instead of the left.
  309. E.g. foldright f a [a1,a2,a3,...,an] = f a1 (f a2 (f a3 (...(f an a)...)))
  310. It is defined in terms of accumulate in order to benefit from
  311. tail recursion optimisation.
  312.  
  313. cons : 'a -> 'a list -> 'a list   
  314. cons is a curried version of the list constructor.
  315.  
  316. maxposlist : int list -> int   
  317. maxposlist x is equivalent to maxlist(0::x) and produces 0 if
  318. x is empty or if x contains only negative integers.
  319.  
  320. member : ''a list -> ''a -> bool   
  321. a test for membership of a list. member [2,4,7,9] 7 = true
  322.  
  323. assoc : (''a -> 'c) -> ((''a * 'c) list) -> ''a -> 'c
  324. This complex looking function essentially builds a function
  325. from a list of pairs (representing a mapping).
  326. It takes an additional parameter, 
  327. namely: a default function to be used if no match is found.
  328. E.g. fun example = assoc I [(2,4),(3,9)]
  329. Then example 2 = 4, example 3 = 9 and example x = x for any
  330. other int x.
  331.  
  332. append : 'a list -> 'a list -> 'a list   
  333. append is a curried form for the infix operator @
  334.  
  335. null : 'a list -> bool   
  336. The predicate null asks if a list is empty
  337.  
  338. hd : 'a list -> 'a   
  339. The selector hd and tl returns the first item
  340. when applied to a non empty list. 
  341. It raises ex_undefined if applied to the empty list.
  342.  
  343. revonto : 'a list -> 'a list -> 'a list   
  344. revonto x y is the list produced by reversing list y onto the
  345. front of x. e.g. revonto x [a1,a2,...,an] = [an,...a2,a1] @ x
  346.  
  347. linkwith : 'a list * 'a list * 'a list -> 'a list list -> 'a list
  348. linkwith (front,sep,back) l  links together a list of lists l  
  349. into a single list seperating each list with the list sep and
  350. surrounding the result by  the lists front and back.
  351. e.g. linkwith (front,sep,back) [a1,a2,a3,...an]
  352.       = front @ a1 @ sep @ a2 @ sep @ a3 @ sep ... @ an @ back
  353.  
  354. copy : int -> 'a -> 'a list   
  355. copy n x produces a list n copies of x (n>=0) and raises abort if n<0.
  356.  
  357. splice : ('a -> 'a -> 'a) -> 'a list -> 'a list -> 'a list   
  358. splice extends two place functions to act on lists in the same
  359. way as zip. The difference is that splice appends the remainder
  360. of the longer list if given lists of different lengths and it
  361. has a more restrictive type.
  362. e.g. splice f [a1,a2,...,an] [b1,b2,...,bm] 
  363.       = [f a1 b1, f a2 b2, ... , f an bn] @ [bn',...,bm] 
  364.       when n <= m (n'=n+1) and similarly. 
  365.       = [f a1 b1, f a2 b2, ... , f am bm] @ [am',...,an] 
  366.       when m <= n (m'=m+1). 
  367.  
  368. forall : ('a -> bool) -> 'a list -> bool   
  369. forall p x is true if every item in x satisfies p and is
  370. false otherwise.
  371.  
  372. sumlist : int list -> int   
  373. sumlist x produces the sum of the integers in list x.
  374.  
  375. mullist : int list -> int
  376. mullist x produces the product of the integers in list x.
  377.  
  378. length : 'a list -> int   
  379. length x returns the length of list x.
  380.  
  381. drop : int -> 'a list -> 'a list
  382. drop n x is the remainder of list x after dropping the
  383. first n items.
  384. It raises ex_undefined when n<0 and when n>length x.
  385.  
  386. filter : ('a -> bool) -> 'a list -> 'a list   
  387. filter p x returns the sublist of those items in list x which
  388. satisfy the predicate p (in the same order as they appear in x).
  389. back : int -> 'a list -> 'a list
  390. back n x is the last n items of list x.
  391. It raises ex_undefined when n<0 and when n>length x
  392.  
  393. upto : int * int -> int list   
  394. upto is an infix operator. "n upto m" produces the ascending
  395. list of integers between and including n and m (n<=m)
  396. and is [] if n>m. e.g. 3 upto 7 = [3,4,5,6,7]
  397. YOU MAY NEED to reaffirm 'infix upto;'
  398. before using it this way.
  399.  
  400. front : int -> 'a list -> 'a list
  401. front n x is the first n items of x.
  402. It raises ex_undefined when n<0 and when n>length x.
  403.  
  404. select : int -> 'a list -> 'a   
  405. select n x returns the nth item in list x
  406. (starting at 1 for the head).
  407. It raises ex_undefined when n is too large and when n<1.
  408.  
  409. pairlists : 'a list -> 'b list -> ('a * 'b) list   
  410. pairlists forms a list of pairs by combining two lists
  411. componentwise e.g.
  412. pairlists [a1,a2, ..., an] [b1,b2,...,bn] = [(a1,b1),(a2,b2),...,(an,bn)]
  413. pairlists raises ex_undefined if the list lengths are not the same.
  414.  
  415. split : int -> 'a list -> ('a list * 'a list)
  416. split n x returns a pair of lists consisting of the front n
  417. items of x and the rest of x, respectively. 
  418. It raises ex_undefined when n<0 and when n>length x.
  419.  
  420. sublist : int -> int -> 'a list -> 'a list
  421. sublist n m x is the list of m items starting with and
  422. following on from the nth item of x.
  423. It raises ex_undefined when n<1 and when m<0 and when n+m-1>length x.
  424.  
  425. transpose : 'a list list -> 'a list list   
  426. transpose takes a list of lists thought of as rows of a matrix and   
  427. produces the list of lists representing columns.
  428. Any rows longer than the shortest row will be clipped.   
  429.  
  430. tl : 'a list -> 'a list
  431. The selector hd and tl returns the list without the first item
  432. when applied to a non empty list. 
  433. It raises ex_undefined if applied to the empty list.
  434.  
  435. fold : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a   
  436. fold combines items in a list with a two place function and a
  437. default value to reduce the list.
  438. e.g. fold f a [a1,a2,a3,...,an] = f (f...(f (f a a1) a2) a3) ...an
  439.  
  440. reverse : 'a list -> 'a list   
  441. reverse just reverses a list and is equivalent to predefined rev.
  442.  
  443. link : 'a list list -> 'a list   
  444. link llist  links together llist (a list of lists) into a single list    
  445. e.g. link [a1,a2,a3,...an] = a1 @ a2 @ a3 @ ... @ an
  446.  
  447. contains : ''a list -> ''a list -> bool   
  448. contains is a list version of set containment.
  449. Testing whether list y contains all the items in x is written:
  450.       contains x y
  451. NOTE THE ORDER OF ARGUMENTS (contains x) is a predicate on lists such as y
  452. contains [2,4,7,9] [3,7,9,5,4,2] = true
  453.  
  454.  
  455. Some Combinators ********************************
  456. uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c   
  457. If f is a function expecting two successive arguments, then
  458. (uncurry f) is a similar function applicable to argument pairs.
  459.  
  460. I : 'a -> 'a
  461. I is the identity function
  462.  
  463. couple : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c
  464. couple is used to apply two functions to the same argument
  465. to return a pair of results.
  466. Thus couple f g a = (f a, g a).
  467.  
  468. K : 'a -> 'b -> 'a   
  469. K forms constant functions, so that K x returns x when applied
  470. to anything
  471.  
  472. curry : ('a * 'b -> 'c) -> 'a -> 'b -> 'c   
  473. If f is a function expecting an argument pair, then (curry f)
  474. is a similar function expecting the arguments one at a time
  475.  
  476. snd : 'a * 'b -> 'b
  477. snd returns the second item from a pair
  478.  
  479. W = fn : ('a -> 'a -> 'b) -> 'a -> 'b
  480. W duplicates an argument for a curried function (W f a =  f a a)
  481. Y : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b   
  482. Y is the fixed point combinator. If F is an operation on functions 
  483. returning a function of the same type, then Y F is the (least) 
  484. fixed point of F satisfying F(Y F) = (Y F).
  485.  
  486. repeat : ('a -> 'a) -> int -> 'a -> 'a   
  487. repeat f n x is equivalent to n applications of f to x, i.e.
  488. f (f (f...(f x)..)).
  489. However, if n<0 then repeat f n x raises ex_undefined.
  490.  
  491. C : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c   
  492. C swaps the arguments for a curried function so (C f) x y = f y x.
  493.  
  494. pair : 'a -> 'b -> 'a * 'b   
  495. pair is a curried function constructing pairs.
  496.  
  497. fst : 'a * 'b -> 'a
  498. fst returns the first item from a pair
  499.  
  500. Operations on Strings *************************
  501. slesseq : string -> string -> bool
  502. curried <= for strings where slesseq s1 s2 = s2<=s1
  503. NOTE argument order.
  504.  
  505. sless : string -> string -> bool
  506. curried < for strings where sless s1 s2 = s2<s1
  507. NOTE argument order.
  508.  
  509. stringofint : int -> string
  510. converts any integer to its decimal representation as a string
  511.  
  512. stringwith : string * string * string -> string list -> string
  513. stringwith is a string version of linkwith.
  514. E.g. stringwith (front,sep,back) [s1,s2,s3,...,sn]
  515.       = front ^ s1 ^ sep ^ s2 ^ sep ^ ... ^ sn ^ back
  516.  
  517. spaces : int -> string
  518. spaces n is a string of n space chars (n>=0) and raises
  519. ex_undefined if n<=0.
  520.  
  521. newlines : int -> string
  522. newlines n is a string of n newline chars (n>=0) raises
  523. ex_undefined if n<=0.
  524.  
  525. show : string -> unit   
  526. show prints a string at the terminal as a side effect.
  527. For functional programming, it should only be used at top level
  528. for  displaying strings in their crude form
  529. (with control characters interpreted) or for defining other,
  530. similarly restricted, display functions.
  531.  
  532. concat : string -> string -> string   
  533. concat is a curried version of the string concatenator ^
  534.  
  535. Integer Arithmetic
  536. greatereq : int -> int -> bool   
  537. greatereq is a curried version of < for integers
  538. BUT NOTE THE ORDER OF ARGUMENTS
  539. (greatereq a) is a predicate which when applied to b returns true if b>=a.
  540.  
  541. min : int -> int -> int   
  542. min a b returns the smaller of integers a and b
  543.  
  544. greater : int -> int -> bool   
  545. greater is a curried version of > for integers
  546. BUT NOTE THE ORDER OF ARGUMENTS
  547. (greater a) is a predicate which when applied to b returns true if b>a.
  548.  
  549. max : int -> int -> int   
  550. max a b returns the larger of integers a and b
  551.  
  552. lesseq : int -> int -> bool   
  553. lesseq is a curried version of <= for integers
  554. BUT NOTE THE ORDER OF ARGUMENTS
  555. (lesseq a) is a predicate which when applied to b returns true if b<=a.
  556.  
  557. times : int -> int -> int   
  558. times is a curried version of * for integers
  559.  
  560. less : int -> int -> bool   
  561. less is a curried version of < for integers
  562. BUT NOTE THE ORDER OF ARGUMENTS
  563. (less a) is a predicate which when applied to b returns true if b<a.
  564.  
  565. plus : int -> int -> int   
  566. plus is a curried version of + for integers
  567.  
  568. **************************************************)
  569.